package com.hs.srm.admin.common.interceptor;

import org.apache.shiro.aop.MethodInvocation;
import org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Description:shiro注解拦截器
 * @Author ych
 * @date 2020/02/15
 */
public class ShiroAopAnnotationInterceptor extends AopAllianceAnnotationsAuthorizingMethodInterceptor {

    private static final Logger logger = LoggerFactory.getLogger(ShiroAopAnnotationInterceptor.class);
    /**
     * shiro默认抛出异常，改写方法，后台不报错，记录错误日志
     * @param methodInvocation
     * @return
     * @throws Throwable
     */
    @Override
    public Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation) throws Throwable {
        MethodInvocation mi = this.createMethodInvocation(methodInvocation);
        Object invoke=null;
        try{
            invoke = super.invoke(mi);
        }catch (Exception e){
            //logger.error(e.getMessage());
        }
        return invoke;
    }
}
